﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Handrise.BasicModal.Serialization;

namespace Handrise.CDCable.Business
{
    /// <summary>
    /// 测温服务
    /// </summary>
    public class TempratureService
    {
        private ServerExchange serverExchange = new ServerExchange();

        /// <summary>
        /// 上传测温信息
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="tempraturesBuffer">测温实体列序列化流</param>
        /// <returns></returns>
        public bool UploadTemprature(string userName, byte[] tempraturesBuffer)
        {
            CompactFormatterPlus cfp = new CompactFormatterPlus();
            List<Temprature> tempratures = (List<Temprature>)cfp.Deserialize(tempraturesBuffer);

            string entitysXML = CommonFunction.GetXMLFromEnitys<Temprature>(tempratures, typeof(Temprature));

            string receiveData = serverExchange.UploadTemprature(userName, entitysXML);

            return CommonFunction.ReturnDataIsOk(receiveData); ;
        }
    }
}
